Documentation > CMS Template API Library > Util > LoadXml(String,String,Dictionary[String,String])

LoadXml

Converts the xml into a list of XmlNodes. Passing a value for elementName will return the subset of nodes that are contained within the elementName node.

public List<XmlNode> LoadXml(String,String,Dictionary[String,String])

Parameters

NameDescriptionType
xml The xml string to convert into a list of XmlNodes System.String
elementName The name of the element to build the list from System.String
namespaces Dictionary of prefixes to xml namespaces Dictionary<String,String>

Code Example

C#

Sample:

            
            EmailAttachment attachment = context.EmailAttachments[0];
            List<XmlNode> xmlNodeList = Util.LoadXml(attachment.StringValue, "node");
            foreach (XmlNode node in xmlNodeList)
            {
              foreach (XmlNode elementNode in node.XmlNodes)
              {
                if(elementNode.Name == "content")
                {
                  if(elementNode.Attributes["lang"] == "ja-JP")
                  {
                    asset["page_body"] = Util.EscapeItem(elementNode.Value);
                  }
                }
              }
            }
            
            

Connect with Crownpeak